/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package entidades;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Daniel Cruz
 */
@Entity
@Table(name = "autor")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Autor.findAll", query = "SELECT a FROM Autor a"),
    @NamedQuery(name = "Autor.findByIdAut", query = "SELECT a FROM Autor a WHERE a.idAut = :idAut"),
    @NamedQuery(name = "Autor.findByPrimerNombreAut", query = "SELECT a FROM Autor a WHERE a.primerNombreAut = :primerNombreAut"),
    @NamedQuery(name = "Autor.findBySegundoNombreAut", query = "SELECT a FROM Autor a WHERE a.segundoNombreAut = :segundoNombreAut"),
    @NamedQuery(name = "Autor.findByPrimerApellidoAut", query = "SELECT a FROM Autor a WHERE a.primerApellidoAut = :primerApellidoAut"),
    @NamedQuery(name = "Autor.findBySegundoApellidoAut", query = "SELECT a FROM Autor a WHERE a.segundoApellidoAut = :segundoApellidoAut"),
    @NamedQuery(name = "Autor.findByPaisAut", query = "SELECT a FROM Autor a WHERE a.paisAut = :paisAut")})
public class Autor implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "id_aut")
    private Long idAut;
    @Size(max = 2147483647)
    @Column(name = "primer_nombre_aut")
    private String primerNombreAut;
    @Size(max = 2147483647)
    @Column(name = "segundo_nombre_aut")
    private String segundoNombreAut;
    @Size(max = 2147483647)
    @Column(name = "primer_apellido_aut")
    private String primerApellidoAut;
    @Size(max = 2147483647)
    @Column(name = "segundo_apellido_aut")
    private String segundoApellidoAut;
    @Size(max = 2147483647)
    @Column(name = "pais_aut")
    private String paisAut;
    @JoinTable(name = "escribe", joinColumns = {
        @JoinColumn(name = "id_aut", referencedColumnName = "id_aut")}, inverseJoinColumns = {
        @JoinColumn(name = "material_id", referencedColumnName = "material_id")})
    @ManyToMany
    private Collection<Material> materialCollection;
    @JoinColumn(name = "bat_id_pais", referencedColumnName = "bat_id")
    @ManyToOne
    private BBasicaTipo batIdPais;

    public Autor() {
    }

    public Autor(Long idAut) {
        this.idAut = idAut;
    }

    public Long getIdAut() {
        return idAut;
    }

    public void setIdAut(Long idAut) {
        this.idAut = idAut;
    }

    public String getPrimerNombreAut() {
        return primerNombreAut;
    }

    public void setPrimerNombreAut(String primerNombreAut) {
        this.primerNombreAut = primerNombreAut;
    }

    public String getSegundoNombreAut() {
        return segundoNombreAut;
    }

    public void setSegundoNombreAut(String segundoNombreAut) {
        this.segundoNombreAut = segundoNombreAut;
    }

    public String getPrimerApellidoAut() {
        return primerApellidoAut;
    }

    public void setPrimerApellidoAut(String primerApellidoAut) {
        this.primerApellidoAut = primerApellidoAut;
    }

    public String getSegundoApellidoAut() {
        return segundoApellidoAut;
    }

    public void setSegundoApellidoAut(String segundoApellidoAut) {
        this.segundoApellidoAut = segundoApellidoAut;
    }

    public String getPaisAut() {
        return paisAut;
    }

    public void setPaisAut(String paisAut) {
        this.paisAut = paisAut;
    }

    @XmlTransient
    public Collection<Material> getMaterialCollection() {
        return materialCollection;
    }

    public void setMaterialCollection(Collection<Material> materialCollection) {
        this.materialCollection = materialCollection;
    }

    public BBasicaTipo getBatIdPais() {
        return batIdPais;
    }

    public void setBatIdPais(BBasicaTipo batIdPais) {
        this.batIdPais = batIdPais;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idAut != null ? idAut.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Autor)) {
            return false;
        }
        Autor other = (Autor) object;
        if ((this.idAut == null && other.idAut != null) || (this.idAut != null && !this.idAut.equals(other.idAut))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.Autor[ idAut=" + idAut + " ]";
    }
    
}
